package com.stox.parser;

import java.util.StringTokenizer;

import org.springframework.stereotype.Component;

import com.stox.model.entity.ExchangeEntity;
import com.stox.model.entity.ScripEntity;

@Component
public class BseScripParser {

	public ScripEntity parse(ExchangeEntity exchange, String str){
		ScripEntity scrip = new ScripEntity();
		scrip.setExchange(exchange);
		StringTokenizer t = new StringTokenizer(str,",",false);
		try{
			scrip.setCode(t.nextToken());
			scrip.setName(t.nextToken());
			scrip.setScripGroup(t.nextToken().trim().toUpperCase());
			scrip.setType(t.nextToken().trim().toUpperCase());
			if(!"Q".equals(scrip.getType()))	return null;
			}catch(Exception e){
				e.printStackTrace();
				scrip = null;
			}
		return scrip;
	}
	
}
